<template>
  <Layout class="menu-left">
    <Menu mode="horizontal" @on-select='lowerStep' :active-name="modaleshow">
      <MenuItem :name="1">设备设施风险</MenuItem>
      <MenuItem :name="2">作业流程风险</MenuItem>
      <MenuItem :name="3">人员岗位风险</MenuItem>
      <MenuItem :name="4">环境氛围风险</MenuItem>
    </Menu>

    <Form ref="form1" :model="form1" :label-width="120">
      <Row class="query-form" style="padding-top: 10px" v-show="!switchFlag">
        <Col span="8">
          <FormItem label="风险类别：">
            <Select filterable v-model="form1.riskType"
                    :label-in-value="true">
              <Option v-for="item in riskTypeArr" :value="item.codingCodeId" :label="item.codingName">
                {{ item.codingName }}
              </Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="风险识别维度：">
            <!--    <Input type="text" v-model="form1.rikDiscernName"/>-->
            <Select v-model="form1.rikDiscernName">
              <Option v-for="item in rikDiscernList" :value="item.codingCodeId" :label="item.codingName">
                {{ item.codingName }}
              </Option>
            </Select>
          </FormItem>
        </Col>

        <Col span="8">
          <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
          <Button @click="reset" class="ivu-btn-reset">重置</Button>
          <Button class="ivu-btn-query" icon="md-search" @click="query()">查询</Button>
        </Col>
      </Row>
      <Row v-show="switchFlag" class="query-form" style="padding-top: 10px">
        <Col span="8">
          <FormItem label="风险类别：">
            <Select filterable v-model="form1.riskType"
                    :label-in-value="true">
              <Option v-for="item in riskTypeArr" :value="item.codingCodeId" :label="item.codingName">
                {{ item.codingName }}
              </Option>
            </Select>
          </FormItem>
        </Col>

        <Col span="8">
          <FormItem label="风险识别维度：">
            <!--  <Input type="text" v-model="form1.rikDiscernName"/>-->
            <Select v-model="form1.rikDiscernName">
              <Option v-for="item in rikDiscernList" :value="item.codingCodeId" :label="item.codingName">
                {{ item.codingName }}
              </Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="风险等级：">
            <!-- <Input type="text" v-model="form1.rikRankId"/>-->
            <Select v-model="rikRanks" multiple style="width:100%">
              <Option v-for="item in rikRankList" :value="item" :key="item">{{ item }}</Option>
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row v-show="switchFlag" class="query-form">

        <Col span="8">
          <FormItem label="一级风险单元：">
            <Input type="text" v-model="form1.riskUnit"/>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="二级风险单元：">
            <Input type="text" v-model="form1.riskUnit2"/>
          </FormItem>
        </Col>

        <Col span="8">
          <FormItem label="三级风险单元：">
            <Input type="text" v-model="form1.riskUnit3"/>
          </FormItem>
        </Col>
      </Row>
      <Row v-show="switchFlag" class="query-form">

        <Col span="8">
          <FormItem label="四级风险单元：">
            <Input type="text" v-model="form1.riskUnit4"/>
          </FormItem>
        </Col>
        <Col span="8" offset="8">
          <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
          <Button @click="reset" class="ivu-btn-reset">重置</Button>
          <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
      </Row>

    </Form>
    <Row class="query-form">
      <Col span="24">
        <Button size="large" class="ivu-btn-add" icon="md-add" @click="submitSelect">批量审核</Button>
      </Col>
    </Row>
    <Table ref='table' :loading="loading" :height="tableHeight" size="small" class="no-add-table"
           no-data-text="没有查询到相关数据!" @on-selection-change="reportSelect"
           highlight-row stripe border :columns="columns1" width="100%" :data="dataTable">
    </Table>
    <Row style="margin-right:10px;">
      <Col span="24">
        <Page :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
              style="float: right" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
              show-total show-sizer show-elevator/>
      </Col>
    </Row>

    <Modal :transfer=false v-model="model1" :width=1000>
      <p slot="header">
        <span v-if="modaleshow==1">设备设施风险</span>
        <span v-else-if="modaleshow==2">作业流程风险</span>
        <span v-else-if="modaleshow==3">人员岗位风险</span>
        <span v-else>环境氛围风险</span>
      </p>
      <Form :model="InputData">
        <div v-if="modaleshow==1">
          <equipmentFacilitiesRiskApproval ref="equipmentFacilitiesRiskApproval"
                                           :InputData="InputData"></equipmentFacilitiesRiskApproval>
        </div>
        <div v-else-if="modaleshow==2">
          <workProcessRiskApproval ref="workProcessRiskApproval"
                                   :InputData="InputData"></workProcessRiskApproval>
        </div>
        <div v-else-if="modaleshow==3">
          <personnelJobRiskApproval ref="personnelJobRiskApproval"
                                    :InputData="InputData"></personnelJobRiskApproval>
        </div>
        <div v-else>
          <environmentalRiskApproval ref="environmentalRiskApproval"
                                     :InputData="InputData"></environmentalRiskApproval>
        </div>
        <hr style="margin-top: 10px;color: #dcdcdc"/>
        <div style="margin-top: 10px">
          <Row style="line-height: 35px;">
            <Col span='2'>
              <b>风险审核</b>
            </Col>
            <Col span='6' offset="1">
                            <span v-if="add">审核结果：
                              <Select v-model="saRiskAduitTransfer.auditResult">
                                    <Option value="0">通过</Option>
                                    <Option value="1">审核驳回</Option>
                                </Select>
                            </span>
              <span
                  v-else>审核结果：{{ saRiskAduitTransfer.auditResult == '0' ? '通过' : saRiskAduitTransfer.auditResult == '0' ? '审核驳回' : '' }}</span>
            </Col>
            <Col span='6' offset="1">
              <span>审核人：{{ InputData.saRiskAssess.checkerName }}</span>
            </Col>
            <Col span='6' offset="1">
              <span>审核时间：{{ saRiskAduitTransfer.auditTime }}</span>
            </Col>
          </Row>
          <Row style="line-height: 35px" v-show="add">
            <Col span='18' offset="3">
              <FormItem label='意见：' prop="rectifyRequire">
                <Input v-model="saRiskAduitTransfer.rectifyRequire" type="textarea"
                       :autosize="{minRows:2,maxRows:5}"/>
              </FormItem>
            </Col>
          </Row>
          <Row style="line-height: 35px" v-show="!add" class="detail-background-clor">
            <Col span='18' offset="3">
              <span>意见：{{ saRiskAduitTransfer.rectifyRequire }}</span>
            </Col>
          </Row>
        </div>

        <!-- <Row type="flex" justify="space-around" class="code-row-bg">
             <Col span="23">
                 <FormItem>
                     <div v-if="add">
                         <Button class='ivu-btn-save' @click="submit('InputData')">确定</Button>
                         <Button class='ivu-btn-cancel' @click="model1=false;saRiskAduitTransfer={}">取消</Button>
                     </div>
                     <div v-else>
                         <Button class='ivu-btn-save' @click="model1=false;saRiskAduitTransfer={}">关闭</Button>
                     </div>
                 </FormItem>
             </Col>
         </Row>-->
      </Form>
      <div slot="footer">
        <div v-if="add">
          <Button class='ivu-btn-save' :loading="buttonLoading" @click="submit('InputData')">确定</Button>
          <Button class='ivu-btn-cancel' @click="model1=false;saRiskAduitTransfer={}">取消</Button>
        </div>
        <div v-else>
          <Button class='ivu-btn-save' @click="model1=false;saRiskAduitTransfer={}">关闭</Button>
        </div>
      </div>
    </Modal>

    <Modal title="批量审核" :transfer=false v-model="reportSelectModel" :width=700>
      <Form ref='dataView' :model="dataView" :rules="reportRuleCustom" label-position="top">
        <Row>
          <Col span='23'>
            <FormItem label='审批结果：' prop="auditResult">
              <Select v-model="dataView.auditResult">
                <Option value="0">通过</Option>
                <Option value="1">审核驳回</Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span='23'>
            <FormItem label='意见：' prop="rectifyRequire">
              <Input v-model="dataView.rectifyRequire" type="textarea"
                     :autosize="{minRows:2,maxRows:5}"/>
            </FormItem>
          </Col>
        </Row>

      </Form>
      <div slot="footer">
        <Button class='ivu-btn-save'  :loading="buttonLoading"
                @click="submitSelectAll('dataView')">确定
        </Button>
        <Button class='ivu-btn-cancel' @click="onCancel">取消</Button>
      </div>
    </Modal>
  </Layout>
</template>
<script>
import {Api} from '../../../../api/index.js'
import {sessionStorage} from '../../../../common/cacheUtils.js';
import equipmentFacilitiesRiskApproval from './equipmentFacilitiesRiskApproval.vue'
import workProcessRiskApproval from './workProcessRiskApproval.vue'
import personnelJobRiskApproval from './personnelJobRiskApproval.vue'
import environmentalRiskApproval from './environmentalRiskApproval.vue'

export default {
  components: {
    equipmentFacilitiesRiskApproval,
    environmentalRiskApproval,
    workProcessRiskApproval,
    personnelJobRiskApproval
  },
  name: "riskApproval",//风险审核
  data() {
    return {
      reportSelectModel: false,
      reportSelectAll: [],
      tableHeight: '',
      pageSizeArray: [10, 20, 50, 100, 200],
      rikDiscernList: [],
      riskTypeArr: [],
      rikRankList: ["重大", "较大", "一般", "低"],
      rikRanks: [],
      switchFlag: false,
      buttonLoading: false,
      reportRuleCustom: {
        auditResult: [{
          validator: (rule, value, callback) => {
            if (this.dataView.auditResult == null || this.dataView.auditResult == '' || this.dataView.auditResult == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        rectifyRequire: [{
          validator: (rule, value, callback) => {
            if (this.dataView.rectifyRequire == null || this.dataView.rectifyRequire == '' || this.dataView.rectifyRequire == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],

      },
      pagedata: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      dataView:{},
      dataTable: [],
      loading: false,
      columns: [
        {
          type: 'selection',
          width: 60,
          fixed: 'left',
          align: 'center'
        },
        {
          title: "序号",
          minWidth: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
          }
        },
        {
          width: 200,
          minWidth: 150,
          title: '一级风险单元',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.riskUnitName)
          }
        },
        {
          width: 200,
          minWidth: 150,
          title: '二级风险单元',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.riskUnit2)
          }
        },
        {
          width: 200,
          minWidth: 150,
          title: '三级风险单元',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.riskUnit3)
          }
        }, {
          width: 200,
          minWidth: 150,
          title: '四级风险单元',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.riskUnit4)
          }
        }, {//设备
          width: 200,
          minWidth: 150,
          title: '设备设施名称',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.equipmentName)
          }
        }, {
          width: 200,
          minWidth: 150,
          title: '子系统单元或重要元器件',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.subEqName)
          }
        },//设备
        {
          width: 200,
          minWidth: 150,
          title: '人员岗位',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.personnelPosition)
          }
        },
        {
          width: 200,
          minWidth: 150,
          title: '作业内容',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.workContent)
          }
        },
        {
          width: 150,
          title: '风险类别',
          align: 'center',
          key: 'riskTypeName',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.riskTypeName)
          }
        },
        {
          width: 150,
          title: '风险识别维度',
          align: 'center',
          key: 'rikDiscernName',
          render: (h, params) => {
            return h('span', params.row.saRiskInfo.rikDiscernName)
          }
        },
        {
          width: 150,
          title: '风险等级',
          align: 'center',
          key: 'rikRankName',
        },
        {
          width: 150,
          title: '风险警示色',
          align: 'center',
          key: 'rikColor',
          /* render: (h, params) => {
               // 需要延迟处理，否则颜色无法赋值
               setTimeout(() => {
                   let dom = document.getElementsByClassName(`${params.row.cellClassName.rikColor}`)
                   dom[0].style.backgroundColor = `${params.row.cellClassName.rikColor}`
               }, 100)
               return h('div', {
                   style: {
                       color: 'black'
                   }
               }, params.row.rikColor)
           }*/
        },
        {
          width: 150,
          title: '风险防范措施',
          align: 'center',
          key: 'manageMeasure',
          ellipsis: 'true',
          render: (h, params) => {
            return h('span', params.row.saRiskManage.manageMeasure)
          }
        },
        {
          width: 150,
          title: '应急措施',
          align: 'center',
          key: 'emerMearsure',
          ellipsis: 'true',
          render: (h, params) => {
            return h('span', params.row.saRiskManage.emerMearsure)
          }
        },
        {
          width: 150,
          title: '责任部门',
          align: 'center',
          key: 'dutyOrgName',
          render: (h, params) => {
            return h('span', params.row.saRiskManage.dutyOrgName)
          }
        },
        {
          width: 150,
          title: '责任人',
          align: 'center',
          key: 'dutyPersonName',
          render: (h, params) => {
            return h('span', params.row.saRiskManage.dutyPersonName)
          }
        },
        {
          width: 100,
          title: '审核状态',// 0：未审核1：审核中 2：已审核 3：审核驳回 4：复评价
          align: 'center',
          key: 'rikDiscernName',
          render: (h, params) => {
            return h('span', {
              style: {
                color: params.row.saRiskAssess.auditState == '1' ? 'red' : 'black',
              }
            }, params.row.saRiskAssess.auditState == '1' ? '待审核' : params.row.saRiskAssess.auditState == '3' ? '审核驳回' : '已审核')
          }
        },
        {
          title: '操作',
          key: 'action',
          fixed: 'right',
          width: 140,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '14px',
                },
                on: {
                  click: () => {
                    this.InputData = params.row;
                    let recordeTime = new Date(params.row.saRiskManage.recordeTime)
                    this.InputData.saRiskManage.recordeTime = recordeTime.getFullYear() + '-' + (recordeTime.getMonth() + 1) + '-' + recordeTime.getDate()
                    if (params.row.saRiskAssess.auditState == '1') {
                      // let auditTime = new Date()
                      // auditTime = auditTime.getFullYear() + '-' + (auditTime.getMonth() + 1) + '-' + auditTime.getDate()
                      this.saRiskAduitTransfer = {
                        auditResult: '',
                        auditTime: '',
                        auditUserId: sessionStorage('userId').getObject('userId').userId,
                        assessId: this.InputData.saRiskAssess.assessId
                      }
                    } else {
                      let auditTime = new Date(params.row.saRiskAduitTransfer.auditTime)
                      auditTime = auditTime.getFullYear() + '-' + (auditTime.getMonth() + 1) + '-' + auditTime.getDate()
                      this.saRiskAduitTransfer = {
                        auditResult: params.row.saRiskAduitTransfer.auditResult,
                        auditTime: auditTime,
                        auditUserId: sessionStorage('userId').getObject('userId').userId,
                        assessId: this.InputData.saRiskAssess.assessId,
                        rectifyRequire: params.row.saRiskAduitTransfer.rectifyRequire
                      }
                    }
                    this.model1 = true;
                    this.add = false
                  }
                }
              }, '详情'),
              h('Divider', {
                props: {
                  type: 'vertical',
                }
              }, ''),
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '14px',
                  color: params.row.saRiskAssess.auditState != '1' ? '#d0d0d0' : 'blue',
                  pointerEvents: params.row.saRiskAssess.auditState != '1' ? 'none' : ''
                },
                on: {
                  click: () => {
                    this.InputData = params.row;
                    let recordeTime = new Date(params.row.saRiskManage.recordeTime)
                    this.InputData.saRiskManage.recordeTime = recordeTime.getFullYear() + '-' + (recordeTime.getMonth() + 1) + '-' + recordeTime.getDate()
                    if (params.row.saRiskAssess.auditState == '1') {
                      this.add = true
                      this.InputData.saRiskAssess.preset = '0'
                      let auditTime = new Date()
                      auditTime = auditTime.getFullYear() + '-' + (auditTime.getMonth() + 1) + '-' + auditTime.getDate()
                      this.saRiskAduitTransfer = {
                        transferId: params.row.saRiskAduitTransfer == null || params.row.saRiskAduitTransfer == undefined ? "" : params.row.saRiskAduitTransfer.transferId,
                        auditResult: '0',
                        auditTime: auditTime,
                        auditUserId: sessionStorage('userId').getObject('userId').userId,
                        assessId: this.InputData.saRiskAssess.assessId
                      }
                    } else {
                      this.add = false
                      let auditTime = new Date(params.row.saRiskAduitTransfer.auditTime)
                      auditTime = auditTime.getFullYear() + '-' + (auditTime.getMonth() + 1) + '-' + auditTime.getDate()
                      this.saRiskAduitTransfer = {
                        transferId: params.row.saRiskAduitTransfer == null || params.row.saRiskAduitTransfer == undefined ? "" : params.row.saRiskAduitTransfer.transferId,
                        auditResult: params.row.saRiskAduitTransfer.auditResult,
                        auditTime: auditTime,
                        auditUserId: sessionStorage('userId').getObject('userId').userId,
                        assessId: this.InputData.saRiskAssess.assessId,
                        rectifyRequire: params.row.saRiskAduitTransfer.rectifyRequire
                      }
                    }
                    this.model1 = true;
                  }
                }
              }, '审核'),
            ]);
          }
        }
      ],
      add: false,
      model1: false,
      InputData: {
        saRiskInfo: {},
        saRiskAssess: {},
        saRiskManage: {},
        saRiskAduitTransfer: {}
      },
      saRiskAduitTransfer: {},
      form1: {
        hazardFactor: '',
        rikRankId: '',
      },
      modaleshow: 1,
    }
  },
  computed: {
    columns1() {
      const columns = [...this.columns];
      const modaleshow = this.modaleshow
      const columns1 = []
      columns.forEach(item => {
        if (modaleshow == 1) {
          if (item.title != '作业内容' && item.title != '人员岗位') {
            columns1.push(item)
          }
        } else if (modaleshow == 2) {
          if (item.title != '设备设施名称' && item.title != '人员岗位' && item.title != '子系统单元或重要元器件') {
            columns1.push(item)
          }
        } else if (modaleshow == 3) {
          if (item.title != '设备设施名称' && item.title != '作业内容' && item.title != '子系统单元或重要元器件') {
            columns1.push(item)
          }
        } else {
          if (item.title != '设备设施名称' && item.title != '作业内容' && item.title != '人员岗位' && item.title != '子系统单元或重要元器件') {
            columns1.push(item)
          }
        }
      })
      return columns1
    },
  },
  mounted() {
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    this.query()
  },
  methods: {
    reportSelect(select) {
      this.reportSelectAll = select

    },
    submit() {
      this.$Modal.confirm({
        title: '数据审核',
        content: '<p>确定提交审批结果?</p>',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          if (this.add) {
            this.buttonLoading = true
            let url = Api.riskApproval
            this.saRiskAduitTransfer.auditTime = new Date(this.saRiskAduitTransfer.auditTime)
            this.$http.post(url, this.saRiskAduitTransfer).then((res) => {
              this.$Message.success('成功');
              this.query()
              this.buttonLoading = false
              this.model1 = false
            }).catch(e => {
              this.$Message.error('请求失败');
            })
          } else {
            this.model1 = false
          }
        },
      });
    },
    lowerStep(name) {
      this.modaleshow = name
      this.query()
    },
    switchQuery(flag) {
      this.switchFlag = flag;
      if (!this.switchFlag) {
        this.tableHeight = this.tableHeight + 88;
      } else {
        this.tableHeight = this.tableHeight - 88;
      }
    },
    query() {
      let url = ''
      let _this = this
      if (this.modaleshow == 1) {
        url = Api.equipmentFacilitiesRiskApprovalList
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10005", function (result) {
          _this.riskTypeArr = result;
        });
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10010", function (result) {
          _this.rikDiscernList = result;
        });
      } else if (this.modaleshow == 2) {
        url = Api.workProcessRiskApprovalList
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10007", function (result) {
          _this.riskTypeArr = result;
        });
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10011", function (result) {
          _this.rikDiscernList = result;
        });
      } else if (this.modaleshow == 3) {
        url = Api.personnelJobRiskApprovalList
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10008", function (result) {
          _this.riskTypeArr = result;
        });
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10012", function (result) {
          _this.rikDiscernList = result;
        });
      } else if (this.modaleshow == 4) {
        url = Api.environmentalRiskApprovalList
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10009", function (result) {
          _this.riskTypeArr = result;
        });
        this.gDic(Api.queryCodeDetailBySortId + "/risk-10013", function (result) {
          _this.rikDiscernList = result;
        });
      }
      let data = {
        startPage: this.pagedata.currentPage,
        size: this.pagedata.pageSize,
        auditState: '1'
      }
      this.form1.rikRankId = "";
      for (let i = 0; i < this.rikRanks.length; i++) {
        this.form1.rikRankId += this.rikRanks[i] + ",";

      }
      this.form1.userId = sessionStorage('userId').getObject('userId').userId
      data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
      this.loading = true;
      this.$http.get(url, {params: data}).then((res) => {
        console.log(res.data);
        res.data.data.data.forEach(item => {
          const sty = item.rikColor == '红' ? 'table-info-cell-red' : item.rikColor == '橙' ? 'table-info-cell-orage' : item.rikColor == '黄' ? 'table-info-cell-yellow' : item.rikColor == '蓝' ? 'table-info-cell-blue' : ''
          item.cellClassName = {rikColor: sty}
          if (item.saRiskAssess.auditState != '1'){
            item._disabled = true
          }
          /* if (item.saRiskAssess.auditState != '0' && item.saRiskAssess.auditState != '3') {
               item._disabled = true
           }*/
        })
        this.dataTable = res.data.data.data;
        this.pagedata.total = res.data.data.totalSize;
        this.loading = false;

      }).catch(e => {
        this.$Message.error("数据获取失败")
        this.loading = false;
      })
    },
    reset() {
      this.form1 = {}
      this.rikRanks = [];
      this.pagedata.currentPage = 1
      this.query()
    },
    pageChange(pageNum) {
      this.pagedata.currentPage = pageNum;
      this.query();
    },
    pageSizeChange(pageSize) {
      this.pagedata.pageSize = pageSize;
      this.query();
    },
    submitSelect() {

      if (this.reportSelectAll.length != 0) {
        this.reportSelectModel = true;
      } else {
        this.$Message.warning("请先勾选风险条目")
      }
      console.log(this.reportSelectAll);
    },
    onCancel() {
      this.reportSelectModel = false;
    },
    submitSelectAll(name){
      this.$refs[name].validate((valid) => {
        // this.saRiskAduitTransfer = {
        //   transferId: params.row.saRiskAduitTransfer == null || params.row.saRiskAduitTransfer == undefined ? "" : params.row.saRiskAduitTransfer.transferId,
        //   auditResult: '0',
        //   auditTime: auditTime,
        //   auditUserId: sessionStorage('userId').getObject('userId').userId,
        //   assessId: this.InputData.saRiskAssess.assessId
        // }
        if (valid) {
          this.buttonLoading = true;
          let _this = this;
          let list = [];
          this.reportSelectAll.forEach(item =>{
            let data = {
              auditUserId:sessionStorage('userId').getObject('userId').userId,
              assessId:item.saRiskAssess.assessId,
              transferId:item.saRiskAduitTransfer == null || item.saRiskAduitTransfer == undefined ? "" : item.saRiskAduitTransfer.transferId,
              rectifyRequire:this.dataView.rectifyRequire,
              auditResult:this.dataView.auditResult
            }
            list.push(data);
          })
          this.$http.post(Api.examineSelect, list).then((res) => {
            _this.$Message.success('成功');
            _this.query()
            _this.reportSelectModel = false;
            _this.buttonLoading = false
          }).catch(e => {
            _this.buttonLoading = false;
            _this.$Message.error('请求失败');
          })

        } else {
          this.$Message.error('请填报完整!');
        }
      })
    }

  }
}
</script>


<style scoped>
@import '../../../../index.css';
</style>
